/*
 * Copyright (c) Jan Šlahora (${USER}) - 2012.
 * Created in IntelliJ IDEA 10.5
 */

/*
 * Created by JFormDesigner on Tue Feb 21 11:10:58 CET 2012
 */

package GUIComponents;

import java.awt.*;
import java.text.DecimalFormat;
import java.util.*;
import javax.swing.*;
import javax.swing.event.*;
import com.jgoodies.forms.factories.*;
import com.jgoodies.forms.layout.*;
import MW.MW;
import statistics.Pravdepodobnosti;

/**
 * @author Karel Novak
 */
public class PravdepodobnostBar extends JPanel {
  public PravdepodobnostBar() {
    initComponents();
    dejRozdeleniPravdepodobnosti();
  }

  private void dejRozdeleniPravdepodobnosti() {
    rozdeleniComboBox.setModel(new DefaultComboBoxModel<>(Pravdepodobnosti.values()));
  }

  public void setValues(double lambda, double chi, double chiKH) {
    DecimalFormat df = new DecimalFormat("##.#####");

    labelLambda.setText(df.format(lambda));
    labelChiKvadrat.setText(df.format(chi));
    labelChiKritickaHodnota.setText(df.format(chiKH));


    String typRozdeleni = rozdeleniComboBox.getSelectedItem().toString();
    String zaver = "Výběr " + ((chi < chiKH) ?  "má " : "nemá ") + "rozdělení " + typRozdeleni;

    labelZaver.setText(zaver);
  }

  public JLabel getLabelChiKvadrat() {
    return labelChiKvadrat;
  }


  private void initComponents() {
    // JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents
    // Generated using JFormDesigner Evaluation license - Karel Novak
    ResourceBundle bundle = ResourceBundle.getBundle("cs");
    label1 = new JLabel();
    scrollPane1 = new JScrollPane();
    rozdeleniComboBox = new JComboBox();
    label2 = new JLabel();
    labelLambda = new JLabel();
    label3 = new JLabel();
    labelChiKvadrat = new JLabel();
    label4 = new JLabel();
    labelChiKritickaHodnota = new JLabel();
    labelZaver = new JLabel();

    //======== this ========

    // JFormDesigner evaluation mark
    setBorder(new javax.swing.border.CompoundBorder()); addPropertyChangeListener(new java.beans.PropertyChangeListener(){public void propertyChange(java.beans.PropertyChangeEvent e){if("border".equals(e.getPropertyName()))throw new RuntimeException();}});

    setLayout(new FormLayout(
      "2*(default, $lcgap), min, $lcgap, left:50dlu, 4dlu, min, 50dlu, min, $lcgap, 50dlu, $lcgap, right:default:grow",
      "default"));

    //---- label1 ----
    label1.setText(bundle.getString("PravdepodobnostBar.label1.text"));
    add(label1, CC.xy(1, 1));

    //======== scrollPane1 ========
    {
      scrollPane1.setViewportView(rozdeleniComboBox);
    }
    add(scrollPane1, CC.xy(3, 1));

    //---- label2 ----
    label2.setText(bundle.getString("PravdepodobnostBar.label2.text"));
    add(label2, CC.xy(5, 1));
    add(labelLambda, CC.xy(7, 1, CC.LEFT, CC.DEFAULT));

    //---- label3 ----
    label3.setText(bundle.getString("PravdepodobnostBar.label3.text"));
    add(label3, CC.xy(9, 1));
    add(labelChiKvadrat, CC.xy(10, 1, CC.LEFT, CC.DEFAULT));

    //---- label4 ----
    label4.setText(bundle.getString("PravdepodobnostBar.label4.text"));
    add(label4, CC.xy(11, 1));
    add(labelChiKritickaHodnota, CC.xy(13, 1));
    add(labelZaver, CC.xy(15, 1));
    // JFormDesigner - End of component initialization  //GEN-END:initComponents
  }

  // JFormDesigner - Variables declaration - DO NOT MODIFY  //GEN-BEGIN:variables
  // Generated using JFormDesigner Evaluation license - Karel Novak
  private JLabel label1;
  private JScrollPane scrollPane1;
  private JComboBox rozdeleniComboBox;
  private JLabel label2;
  private JLabel labelLambda;
  private JLabel label3;
  private JLabel labelChiKvadrat;
  private JLabel label4;
  private JLabel labelChiKritickaHodnota;
  private JLabel labelZaver;
  // JFormDesigner - End of variables declaration  //GEN-END:variables
}
